package lanqiaobeiquestion;

public class Main1 {

	public static void main(String[] args) {
		int[] month = { 0, 31, 28, 31, 30,
				31, 30, 31, 31, 
				30, 31, 30, 31};
		int count = 0;
		for (int i= 1900; i <= 9999; i++) {
			month[2] = 28;
			if (check(i)) {
				month[2] = 29;
			}
			int sum = sumNum(i);
			for (int j = 1; j <= 12; j++) {
				int rightSum0 = sumNum(j);
				for (int k = 1; k <= month[j]; k++) {
					int rightSum = sumNum(k);
					if (sum == rightSum0 + rightSum) {
						count++;
					}
				}
			}
		}
		System.out.println(count);
	}
	
	
	public static boolean check(int year) {
		if ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0) {
			return true;
		}
		return false;
	}
	
	public static int sumNum(int num) {
		int sum = 0;
		while (num != 0) {
			sum += num % 10;
			num /= 10;
		}
		return sum;
	}
}

